package ${package_name}.controller;

import com.chenfan.ccp.plug.http.annotation.Consume;
import com.chenfan.ccp.plug.http.util.ConsumeUtil;
import com.chenfan.ccp.entity.Response;
import com.chenfan.ccp.util.tool.IdUtil;
import ${package_name}.service.${class_name}Service;
import ${package_name}.vo.${class_name}Vo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
${import_package}


/**
* ${entity_name}的操作接口
*/
@RestController
@RequestMapping("${base_url}")
public class ${class_name}Controller {

@Autowired
p4jprivate ${class_name}Service ${lower_class_name}Service;

/**
* 添加或者修改${entity_name} %np4j*
${param_comment} %n
p4j*%n
p4j*                 code==500,代表服务器出错,请先检测参数类型是否正确%n
p4j*                 code==400,代表参数不正确%n
p4j*                 code==200,代表请求成功%n
p4j*                 data==0,代表操作不成功%n
p4j*                 data!=0,新增时候data返回的是自增id,修改的时候代表影响的数量%np4j*
* @return
*/
@PostMapping("mod")
p4j@Consume(${class_name}Vo.class)%n
p4jpublic Response mod${class_name}(${param}) {


${class_name}Vo ${lower_class_name}Vo = (${class_name}Vo) ConsumeUtil.getObj();

if (${lower_class_name}Vo == null) {
return Response.error();
}


return Response.success(${lower_class_name}Service.mod${class_name}(${lower_class_name}Vo.copy${class_name}Po()));


}


/**
* 删除${entity_name} %n
p4j*
* @param ids ${entity_name}的Id的集合,例如1,2,3多个用英文,隔开 %n
p4j*%n
p4j*                 code==500,代表服务器出错,请先检测参数类型是否正确%n
p4j*                 code==400,代表参数不正确%n
p4j*                 code==200,代表请求成功%n
p4j*                 data==0,代表操作不成功%n
p4j*                 data!=0,代表影响的数量%np4j*
p4j* @return
*/
@RequestMapping("del")
p4jpublic Response del${class_name}(Long[] ids) {

if (ids == null || ids.length == 0) {
return Response.error();
}

return Response.success(${lower_class_name}Service.del${class_name}ByIds(ids));

}

/**
* 查找${entity_name} %np4j*
* @param page 页数默认第一页
* @param size 每页返回的数量，默认10个
* @param openResponseExplainFlag 如果想查看返回类型的字段说明,请填写任意内容即可查看返回说明
${param_comment} %n
p4j*%n
p4j*                 code==500,代表服务器出错,请先检测参数类型是否正确%n
p4j*                 code==400,代表参数不正确%n
p4j*                 code==200,代表请求成功%n
p4j*                 count!=0,代表当前查询条件总的数量%n
p4j*                 data==0,代表操作不成功%n
p4j*                 data!=0,代表影响的数量%np4j*
* @return
*/
@RequestMapping("find")
p4j@Consume(${class_name}Vo.class)%n
p4jpublic Response find${class_name}(@RequestParam(required = false) Integer page,@RequestParam(required = false) Integer size,@RequestParam(required = false) String openResponseExplainFlag,
${param}) {


p4j${class_name}Vo ${lower_class_name}Vo = (${class_name}Vo) ConsumeUtil.getObj();


if (${lower_class_name}Vo == null) {
return Response.error();
}


if(${lower_class_name}Vo.getId()!=null){

return Response.success(${lower_class_name}Service.find${class_name}ById(${lower_class_name}Vo.getId()));

}

return Response.success(${lower_class_name}Service.find${class_name}ByAll(${lower_class_name}Vo.copy${class_name}Po (),
page,size), IdUtil.getTotal());

}

}
